﻿<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>PS1 成品庫齡150天警示</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">	
    <link rel="stylesheet" href="./4/lumen/bootstrap.css" media="screen">
    <link rel="stylesheet" href="./_assets/css/custom.min.css">
  </head>
  <body>
  <div class="container">
	<form>
	  <fieldset>
		<legend>PS1 成品庫齡150天警示</legend>
		<!--button type="button" id="btnNext" class="btn btn-primary">下一箱</button-->
		<div class="form-group row">
		  <label class="col-sm-2 col-form-label" for="inputDefault">掃碼:</label>
		  <div class="col-sm-4">
		  
		  <input class="form-control" placeholder="P 2D G P8304A0450008310027" id="itemNo" type="text">
		  </div>
		  <div class="col-sm-6">
		   <input readonly="" class="form-control-plaintext" id="msg" style="width:450px" type="text">
		   <h2><input readonly="" class="form-control-plaintext" id="prompt" style="width:450px" type="text"></h2>
		  </div>
		  
		</div>		
	</form>	
	<p class="lead">
    <a class="btn btn-primary btn-lg" href="index.html" role="button">返回</a>
	</p>
	</div>
    <script src="./_vendor/jquery/dist/jquery.min.js"></script>
    <script src="./_vendor/popper.js/dist/umd/popper.min.js"></script>
    <script src="./_vendor/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="./_assets/js/custom.js"></script>
	<script>
	var disks;
	var cks=new Array(4);
		$("#itemNo").keypress(function(e){ //change
		  console.log($("#itemNo").val());
		  var key = e.which;
		  if (key == 13) { 
			temp=$("#itemNo").val().split(/\s+/); // +
		    ymd=temp[3].substring(2,4);
		    yy=temp[3].substring(1,2);
			
			yyyy="201"+yy;
			mm=temp[3].substring(2,3);
			mn="";
			if (mm=='C'){mn="12";}
			if (mm=='B'){mn="11";}
			if (mm=='A'){mn="10";}
			if (mm!='C' && mm!='B' && mm!='A'){
				mn="0"+mm;
			}  
			dd=temp[3].substring(3,5);
			console.log(ymd+";"+yy+";"+mm+";"+dd);
			now = new Date();
			date = new Date(yyyy+'/'+mn+'/'+dd+' 00:00:00' );
			console.log((now.getTime() - date.getTime())/(24 * 60 * 60 * 1000));
			lead= Math.round((now.getTime() - date.getTime())/(24 * 60 * 60 * 1000)).toString();
			console.log("製造日期："+yyyy+'/'+mn+'/'+dd +",庫齡:" + lead + " 天。");
			if(lead>150){
				$("#prompt").val("不允许出库").css('color', 'red');
			}
			else
			$("#prompt").val("允许出库").css('color', 'green');
			$("#msg").val("生产日:"+yyyy+'/'+mn+'/'+dd +",庫齡:"+lead+"天.");
			$( "#itemNo" ).select();
		 }
		});	
		
		
	</script>
  </body>
</html>
